<!doctype html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>缤格</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/swiper.min.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/binge.css"/>
    <script type="text/javascript" src="../../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../../script/swiper.min.js"></script>
    <script type="text/javascript" src="../../script/mobile.js"></script>

    <script type="text/javascript">
        window['adaptive'].desinWidth = 750;
        window['adaptive'].baseFont = 28;
        window['adaptive'].maxWidth = 750;
        window['adaptive'].init();
    </script>
</head>

<body>
<!-- header -->
<div id="header" style="height: 0.9rem; background: #fff; position: fixed; top: 0;left: 0; width: 100%; z-index: 99">
    <div class="header" style="margin-bottom: 0;"  id="doubleClick">
        <!--<div class="head-back">-->
        <!--<a href="javascript:void(0);" tapmode onclick="comeBack()" class="back-btn"></a>-->
        <!--</div>-->
        <div class="head-title">
            <h6>学校</h6>
        </div>
        <div class="head-action">
            <a href="javascript:void(0);" tapmode onclick="commonUrl('follow_school')" class="action-btn"></a>
        </div>
    </div>
</div>
<!-- header end -->
<div class="height2" style="height: 1.5rem;"></div>
<!-- change school -->
<div class="school-list">
    <div class="swiper-container">
        <ul class="swiper-wrapper" id="schoolList">
            <!--<li class="swiper-slide on">
                <div class="school-logo">
                    <img src="../../image/school-icon.png" alt="">
                </div>
            </li>
            <li class="swiper-slide">
                <div class="add-school" tapmode onclick="commonUrl('choose_school')"></div>
            </li>-->
        </ul>
    </div>
</div>
<!-- change school end -->

<!-- index-dynamic -->
<div class="school-detail-show">
    <ul>
        <li class="on" data-type="1" data-view="1"><a href="javascript:void(0);">动态</a></li>
        <li data-type="2"><a href="javascript:void(0);" tapmode onclick="toCircle()">圈子</a></li>
        <li data-type="3" data-view="2"><a href="javascript:void(0);">简介</a></li>
        <li data-type="4" data-view="3"><a href="javascript:void(0);">排名</a></li>
    </ul>
</div>
<!-- index-dynamic end -->




<div class="school-section">

    <div class="section" style="display: block;">
        <div class="mescroll" id="mescroll">
            <div class="index-news" style="padding-right: 0.3rem; padding-left: 0.3rem; padding-bottom: 1.45rem;">
                <ul id="newsContent">

                </ul>
            </div>
        </div>
    </div>

    <!--<div class="section" style="display: none;">
        <div class="index-news user-dynamic">
            <ul>
                &lt;!&ndash;三张图&ndash;&gt;
                <li>
                    <div class="common-user-detail">
                        <div class="user-info" tapmode onclick="commonUrl('../activity/person_index')">
                            <div class="user-icon bg-cover"
                                 style="background-image: url('../../image/img-tx.png');"></div>
                            <div class="info">
                                <div class="name">
                                    <h6>后来熟悉</h6>
                                    <dl class="badge-list">
                                        <dd class="icon"><img src="../../icon/icon-hz01.png" alt=""></dd>
                                        <dd class="icon"><img src="../../icon/icon-hz02.png" alt=""></dd>
                                        <dd class="icon"><img src="../../icon/icon-hz03.png" alt=""></dd>
                                        <dd class="icon"><img src="../../icon/icon-hz04.png" alt=""></dd>
                                        <dd class="icon"><img src="../../icon/icon-hz05.png" alt=""></dd>
                                    </dl>
                                </div>
                                <span class="time">1小时前</span>
                            </div>
                        </div>
                        <div class="follow" tapmode onclick="follow()">
                            <span class="no-follow">关注</span>
                            <span class="followed">已关注</span>
                        </div>
                    </div>
                    <div class="video-detail" tapmode onclick="commonUrl()">
                        <h6 class="news-title multiline-ellipsis_3">樊登读书线下沙龙[第九期]清单革命邀您体验新书的试读会，这次的参与人数只有100人。</h6>
                        <div class="detail-img-list">
                            <div class="img bg-cover" style="background-image: url('../../image/img01.png');"></div>
                            <div class="img bg-cover" style="background-image: url('../../image/img02.png');"></div>
                            <div class="img bg-cover" style="background-image: url('../../image/img03.png');"></div>
                        </div>
                        <div class="detail-bottom">
                            <div class="bottom-tips">
                                <span class="bt-pd toUp">精选</span>
                                <span class="bt-pd tips">#读书会#</span>
                                <span class="bt-pd time">3分钟前</span>
                            </div>
                            <div class="bottom-hot">3.3w</div>
                        </div>
                    </div>

                </li>
                &lt;!&ndash;两张图&ndash;&gt;
                <li>
                    <div class="common-user-detail">
                        <div class="user-info" tapmode onclick="commonUrl('../activity/person_index')">
                            <div class="user-icon bg-cover"
                                 style="background-image: url('../../image/img-tx.png');"></div>
                            <div class="info">
                                <div class="name">
                                    <h6>后来熟悉</h6>
                                    <dl class="badge-list">
                                        <dd class="icon"><img src="../../icon/icon-hz01.png" alt=""></dd>
                                        <dd class="icon"><img src="../../icon/icon-hz02.png" alt=""></dd>
                                        <dd class="icon"><img src="../../icon/icon-hz03.png" alt=""></dd>
                                        <dd class="icon"><img src="../../icon/icon-hz04.png" alt=""></dd>
                                        <dd class="icon"><img src="../../icon/icon-hz05.png" alt=""></dd>
                                    </dl>
                                </div>
                                <span class="time">1小时前</span>
                            </div>
                        </div>
                        <div class="follow on" tapmode onclick="follow()">
                            <span class="no-follow">关注</span>
                            <span class="followed">已关注</span>
                        </div>
                    </div>
                    <div class="video-detail" tapmode onclick="commonUrl()">
                        <h6 class="news-title multiline-ellipsis_3">樊登读书线下沙龙[第九期]清单革命邀您体验新书的试读会，这次的参与人数只有100人。</h6>
                        <div class="detail-img-list two-img">
                            <div class="img bg-cover" style="background-image: url('../../image/img01.png');"></div>
                            <div class="img bg-cover" style="background-image: url('../../image/img02.png');"></div>
                        </div>
                        <div class="detail-bottom">
                            <div class="bottom-tips">
                                <span class="bt-pd toUp">精选</span>
                                <span class="bt-pd tips">#读书会#</span>
                                <span class="bt-pd time">3分钟前</span>
                            </div>
                            <div class="bottom-hot">3.3w</div>
                        </div>
                    </div>
                </li>
                &lt;!&ndash;单张图&ndash;&gt;
                <li>
                    <div class="common-user-detail" tapmode onclick="commonUrl('../activity/person_index')">
                        <div class="user-info">
                            <div class="user-icon bg-cover"
                                 style="background-image: url('../../image/img-tx.png');"></div>
                            <div class="info">
                                <div class="name">
                                    <h6>后来熟悉</h6>
                                    <dl class="badge-list">
                                        <dd class="icon"><img src="../../icon/icon-hz01.png" alt=""></dd>
                                        <dd class="icon"><img src="../../icon/icon-hz02.png" alt=""></dd>
                                        <dd class="icon"><img src="../../icon/icon-hz03.png" alt=""></dd>
                                        <dd class="icon"><img src="../../icon/icon-hz04.png" alt=""></dd>
                                        <dd class="icon"><img src="../../icon/icon-hz05.png" alt=""></dd>
                                    </dl>
                                </div>
                                <span class="time">1小时前</span>
                            </div>
                        </div>
                        <div class="follow" tapmode onclick="follow()">
                            <span class="no-follow">关注</span>
                            <span class="followed">已关注</span>
                        </div>
                    </div>
                    <div class="video-detail" tapmode onclick="commonUrl()">
                        <h6 class="news-title multiline-ellipsis_3">樊登读书线下沙龙[第九期]清单革命邀您体验新书的试读会，这次的参与人数只有100人。</h6>
                        <div class="video-box bg-cover" style="background-image: url('../../image/img-video.png')"
                             ;></div>
                        <div class="detail-bottom">
                            <div class="bottom-tips">
                                <span class="bt-pd toUp">精选</span>
                                <span class="bt-pd tips">#读书会#</span>
                                <span class="bt-pd time">3分钟前</span>
                            </div>
                            <div class="bottom-hot">3.3w</div>
                        </div>
                    </div>
                </li>
                &lt;!&ndash;视频&ndash;&gt;
                <li>
                    <div class="common-user-detail" tapmode onclick="commonUrl('../activity/person_index')">
                        <div class="user-info">
                            <div class="user-icon bg-cover"
                                 style="background-image: url('../../image/img-tx.png');"></div>
                            <div class="info">
                                <div class="name">
                                    <h6>后来熟悉</h6>
                                    <dl class="badge-list">
                                        <dd class="icon"><img src="../../icon/icon-hz01.png" alt=""></dd>
                                        <dd class="icon"><img src="../../icon/icon-hz02.png" alt=""></dd>
                                        <dd class="icon"><img src="../../icon/icon-hz03.png" alt=""></dd>
                                        <dd class="icon"><img src="../../icon/icon-hz04.png" alt=""></dd>
                                        <dd class="icon"><img src="../../icon/icon-hz05.png" alt=""></dd>
                                    </dl>
                                </div>
                                <span class="time">1小时前</span>
                            </div>
                        </div>
                        <div class="follow" tapmode onclick="follow()">
                            <span class="no-follow">关注</span>
                            <span class="followed">已关注</span>
                        </div>
                    </div>
                    <div class="video-detail" tapmode onclick="commonUrl()">
                        <h6 class="news-title multiline-ellipsis_3">樊登读书线下沙龙[第九期]清单革命邀您体验新书的试读会，这次的参与人数只有100人。</h6>
                        <div class="video-box bg-cover" style="background-image: url('../../image/img-video.png')" ;>
                            <p class="single-ellipsis">樊登试读会</p>
                            <span class="icon-play"></span>
                            <span class="time">11:28</span>
                        </div>
                        <div class="detail-bottom">
                            <div class="bottom-tips">
                                <span class="bt-pd toUp">精选</span>
                                <span class="bt-pd tips">#读书会#</span>
                                <span class="bt-pd time">3分钟前</span>
                            </div>
                            <div class="bottom-hot">3.3w</div>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </div>-->

    <div class="section" style="display: none;">
        <div class="school-information" style="padding-right: 0.3rem; padding-left: 0.3rem; padding-bottom: 1.45rem">
            <h6>基本资料</h6>
            <ul>
                <li>
                    <p class="label">中文名</p>
                    <div class="label-info" id="cnName"></div>
                </li>
                <li>
                    <p class="label">英文名</p>
                    <div class="label-info" id="enName"></div>
                </li>
                <li>
                    <p class="label">简称</p>
                    <div class="label-info" id="abbreviation"></div>
                </li>
                <li>
                    <p class="label">创办时间</p>
                    <div class="label-info" id="time"></div>
                </li>
                <li>
                    <p class="label">校庆日</p>
                    <div class="label-info" id="anniversary_day"></div>
                </li>
                <li>
                    <p class="label">属性</p>
                    <div class="label-info" id="attribute"></div>
                </li>
                <li>
                    <p class="label">类型</p>
                    <div class="label-info" id="kinds"></div>
                </li>
                <li>
                    <p class="label">王牌专业</p>
                    <div class="label-info" id="major"></div>
                </li>
                <li>
                    <p class="label">高校所在地</p>
                    <div class="label-info" id="address"></div>
                </li>
                <li>
                    <p class="label">隶属于</p>
                    <div class="label-info" id="belong"></div>
                </li>
                <li>
                    <p class="label">亮点</p>
                    <div class="label-info" id="brightSpot"></div>
                </li>
                <li>
                    <p class="label">校训</p>
                    <div class="label-info" id="schoolMotto"></div>
                </li>
                <li>
                    <p class="label">在校生人数</p>
                    <div class="label-info" id="personNum"></div>
                </li>
                <li>
                    <p class="label">男女比例</p>
                    <div class="label-info" id="proportion"></div>
                </li>
            </ul>
        </div>
    </div>

    <div class="section" style="display: none">
        <div class="school-rank" style="padding-right: 0.3rem; padding-left: 0.3rem; padding-bottom: 1.45rem">
            <ul id="ranking">
                <li>
                    <div class="school-info">
                        <div class="school-img">
                            <img src="../../image/school-icon.png" alt="">
                        </div>
                        <div class="info">
                            <h6>浙江大学</h6>
                            <p class="single-ellipsis">最早创办的现代高等学府之一</p>
                        </div>
                    </div>
                    <div class="curr-rank">
                        <p>世界排名</p>
                        <span class="c-primary f30">118</span>名
                    </div>
                </li>

            </ul>
        </div>
    </div>


</div>


<!-- 底部导航 -->
<div id="footer" class="border-t">
    <ul class="flex-wrap">
        <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">首页</li>
        <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">圈子</li>
        <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con active">
            <div class="school-logo">
                <img id="school_path" src="" alt="">
            </div>
        </li>
        <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">在看</li>
        <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">我的</li>
    </ul>
</div>

</body>
</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<link rel="stylesheet" type="text/css" href="../../css/mescroll.min.css"/>
<script type="text/javascript" src="../../script/mescroll.min.js"></script>
<script type="text/javascript">
    var school_id = '';//当前学校id
    var school_type = 1;//当前学校type
    var page = 1;
    var pullUp = false;
    apiready = function () {

        setFixStatusBar(); //设置状态栏

        //监听返回-禁止
        // tabNavListener();

        ExitApp()

        //设置学校logo
        $('#school_path').attr('src', $api.getStorage('schoolPath'));
        //监听设置学校logo
        api.addEventListener({
            name: 'schoolPathStatus'
        }, function (ret, err) {
            $('#school_path').attr('src', $api.getStorage('schoolPath'));
        });

        //监听刷新内容
        api.addEventListener({
            name: 'followSchool'
        }, function (ret, err) {
            getMyschool();
        });

        //选择关注学校返回的监听
        api.addEventListener({
            name: 'refreshSchool'
        }, function (ret, err) {
            getMyschool();
        });


        /*//下拉刷新
        dropDownRefresh(function () {
            getMyschool()
        });*/


        getMyschool()

        SystemCheckVersion()

        isIosX()

    }
    $(".mescroll").height($(window).height() - $("#header").outerHeight(true) - $(".school-list").outerHeight(true) - $(".school-detail-show").outerHeight(true) - $(".height2").outerHeight(true));

    //创建MeScroll对象
    var mescroll = new MeScroll("mescroll", {
        down: {
            auto: false, //是否在初始化完毕之后自动执行下拉回调callback; 默认true
            callback: downCallback //下拉刷新的回调
        },
        up: {
            auto: false, //是否在初始化时以上拉加载的方式自动加载第一页数据; 默认false
            isBounce: true, //此处禁止ios回弹,解析(务必认真阅读,特别是最后一点): http://www.mescroll.com/qa.html#q10// 若为false ,页面上其他地方的滑动都滑不动
            callback: upCallback, //上拉回调,此处可简写; 相当于 callback: function (page) { upCallback(page); }
            /*toTop:{ //配置回到顶部按钮
                src : "../res/img/mescroll-totop.png", //默认滚动到1000px显示,可配置offset修改
                //offset : 1000
            }*/
        }
    });
    /*下拉刷新的回调 */
    function downCallback() {
        getSchoolDetail()
        //mescroll.endErr();
    }

    /*上拉加载的回调 */
    function upCallback() {
        if (pullUp == true) {
            page++;
            getSchoolDetail()
        } else {
            mescroll.endErr();
        }
    }


    //获取关注的学校
    function getMyschool() {
        var param = {
            token: $api.getStorage('token'),
        }
        getAjax(Interface.school_list, param, function (res) {

            var list = res.data;
            var schoolList = '';
            if (isDefine(list)) {
                for (var i = 0; i < list.length; i++) {
                    if (i == 0) {
                        schoolList += '<li class="swiper-slide on">' +
                            '                <div class="school-logo" data-id="' + list[i].id + '">' +
                            '                    <img src="' + ajaxUrl + list[i].icon_path + '" alt="">' +
                            '                </div>' +
                            '            </li>'
                        school_id = list[i].id;//设置第一个学校的学校id
                    } else {
                        schoolList += '<li class="swiper-slide">' +
                            '                <div class="school-logo" data-id="' + list[i].id + '">' +
                            '                    <img src="' + ajaxUrl + list[i].icon_path + '" alt="">' +
                            '                </div>' +
                            '            </li>'
                    }

                }
                var surplus = 10 - list.length;
                for (var j = 0; j < surplus; j++) {
                    schoolList += '<li class="swiper-slide">' +
                        '                <div class="add-school" tapmode onclick=\'commonUrl("choose_school")\'></div>' +
                        '            </li>'
                }
                $("#schoolList").html(schoolList);
                schoolSwiper.updateSlidesSize();

                getSchoolDetail()
            }
            pop.close()
            mescroll.endErr()
        }, function (error) {
            pop.notice(error.msg);
            pop.close()
            mescroll.endErr()
        })

    }

    function getSchoolDetail() {
        var param = {
            token: $api.getStorage('token'),
            type: school_type,
            circle_id: school_id,
            page: page
        }
        console.log(jsonChange(param))
        getAjax(Interface.school_index, param, function (res) {

            var data = res.data;

            if (isDefine(data)) {
                if (school_type == 1) {
                    var listHtml = '';

                    $.each(data,function (i, item) {
                        listHtml += getNewsText(data[i],'','',1)
                    })
                    if(page == 1){
                        $('#newsContent').html(listHtml);
                    }else {
                        $('#newsContent').append(listHtml);
                    }
                    pullUp = true;
                    SystemCheckVersion()
                } else if (school_type == 3) {


                    $("#cnName").html(data.title);//中文名
                    $("#enName").html(data.e_name);//英文名
                    $("#abbreviation").html(data.d_name);//简称
                    $("#time").html(data.c_yer);//创办时间
                    $("#anniversary_day").html(data.anniversary_day);//校庆日
                    $("#attribute").html(data.attribute);//属性
                    $("#kinds").html(data.type_name);//类型
                    $("#major").html(data.w_major);//王牌专业
                    $("#address").html(data.address);//高校所在地
                    $("#belong").html(data.belong_to);//隶属于
                    $("#brightSpot").html(data.bright_sport);//亮点
                    $("#schoolMotto").html(data.school_motto);//校训
                    $("#personNum").html(data.number);//在校生人数
                    $("#proportion").html(data.proportion);//男女比例

                } else if (school_type == 4) {
                    var ranking_list = '';

                    for (var i = 0; i < data.length; i++) {

                            ranking_list += '<li><div class="school-info">' +
                                '                   <div class="school-img bg-cover" style="background: url('+ ajaxUrl + data[i].icon_path +')"></div>' +
                                // '                   <div class="school-img"><img src="' + ajaxUrl + data[i].icon_path + '" alt=""></div>' +
                                '                   <div class="info">' +
                                '                        <h6>' + data[i].title + '</h6>' +
                                '                        <p class="single-ellipsis">' + data[i].content + '</span></p>' +
                                '                   </div>' +
                                '                </div>' +
                                '                <div class="curr-rank">第<span class="c-primary f30">' + data[i].number + '</span>名</div>' +
                                '            </li>';
                    }

                    $("#ranking").html(ranking_list)
                }
            } else {

                if (school_type == 1) {
                    if(page == 1){
                        $('#newsContent').html(noData);
                    }else {
                        $('#newsContent').append('<p class="pt30 pb10 c-999 t-c">没有更多了</p>');
                    }
                    pullUp = false;

                }else if(school_type == 4){
                    $("#ranking").html(noData)

                }

            }

            mescroll.endErr()
        }, function (error) {
            if (school_type == 1) {
                $('#newsContent').html(noData);
            }
            pop.notice(error.msg);
            pop.close();
            mescroll.endErr()
        })
    }

    //选择学校的信息类别
    $(".school-detail-show").on('click', 'li', function () {
        var _this = $(this);
        school_type = _this.attr('data-type');
        var view_id = _this.attr('data-view');
        if (view_id) {
            _this.addClass('on').siblings('li').removeClass('on');
            $(".school-section .section").eq(view_id - 1).show().siblings('.section').hide();
            getSchoolDetail();
        } else {

        }
    });

    //跳转对应圈子
    function toCircle() {
        var param = {
            circle_id: school_id
        }
        commonUrl('../circle/circle_index', param);
    }


    //选择学校
    $(".school-list").on('click', '.school-logo', function () {
        var _this = $(this);
        school_id = _this.attr('data-id');
        _this.parents('li').addClass('on').siblings('li').removeClass('on');
        page = 1;
        if(school_type == 1){
            $('#newsContent').html('');
            $('#mescroll').animate({scrollTop:0},0);//回到顶端
        }
        getSchoolDetail();
    });

    var schoolSwiper = new Swiper('.swiper-container', {
        initialSlide: 1,
        slidesPerView: 5.6,
        observeParents: true,
        freeMode : true,
        freeModeSticky : true,
    });


</script>
